#include "Grid.h"
#include <iostream>

using namespace std;

// ------------------------------------------------------------------- //
// ------------------------ Test de l'objet Node --------------------- //
// ------------------------------------------------------------------- //

int main()
{
	int j = 0;
	bool OneFixed = false;
	bool EndAlgo = false;
	int NbNode = 0;
	Grid Grid_1;

	cout << "Grille initiale:" << endl;

	Grid_1.ExportGrid();

	cout << endl << endl;

	while(EndAlgo == false)
	{
		if(Grid_1.IsFixed(j) == false)
		{
			if(Grid_1.IsFixed(j) == false)
				Grid_1.CheckLine(j);
			if(Grid_1.IsFixed(j) == false)
				Grid_1.CheckColumn(j);
			if(Grid_1.IsFixed(j) == false)
				Grid_1.CheckSquare(j);

			if(Grid_1.IsFixed(j) == true)
				OneFixed = true;
		}

		NbNode++;

		if(j == Grid_1.GetNbColumn() * Grid_1.GetNbColumn() - 1)
		{
			j = 0;
			if (OneFixed == true)
				EndAlgo = false;
			else
				EndAlgo = true;
			OneFixed = false;
		}
		else
			j++;

	}

	cout << "Grille intermédiaire:" << endl;
	Grid_1.ExportGrid();

	cout << endl << endl;
	cout << "Nombre de scan de la grille par le premier algorithme:" << endl;
	cout << NbNode/ (Grid_1.GetNbColumn() * Grid_1.GetNbColumn()-1) << endl;
	cout << endl;

	Grid_1.BackTrack(0);

	cout << "Grille après backtracking:" << endl;
	Grid_1.ExportGrid();


}

